from rest_framework import serializers

from question.models import Label, Question
from question.serializers.questions import QuestionsIdLabelNewLabelsSerializer


class LabelsSerializer(serializers.ModelSerializer):
    class Meta:
        model = Label
        fields = ('id', 'label_name')


# 问题
class QuestionsSerializer(serializers.ModelSerializer):
    labels = QuestionsIdLabelNewLabelsSerializer(many=True)
    user = serializers.StringRelatedField()

    class Meta:
        model = Question
        fields = '__all__'


# 标签详情
class LabelsIDSerializer(serializers.ModelSerializer):
    questions = QuestionsSerializer(many=True)

    class Meta:
        model = Label
        fields = '__all__'
